layui.config({
    base: "js/"
}).use(['form', 'layer', 'jquery', 'laypage'], function () {
    var form = layui.form(),
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        laypage = layui.laypage,
        $ = layui.jquery;

    //查询所有权限
    var treeData = '';
    $.ajax({
        type: "get",
        url: "http://localhost/ci/admin/tree/imp_index",
        data: {'token': localStorage.token},
        async: false,
        success: function (data) {
            dt = new dTree('d');
            treeData = JSON.parse(data);
            dt = renderDate(treeData);
            document.getElementById('aa').innerHTML = dt;
        }
    })

    //渲染数据，向树状图加载信息
    function renderDate(currData) {
        if (currData.length != 0) {
            d = new dTree('d');
            d.add(1, -1, '系统管理');
            for (var i = 0; i < currData.length; i++) {//+'   url:'+ currData[i].url +'   perms:'+ currData[i].perms +'   type:'+currData[i].type +'   icon:'+ currData[i].icon
                d.add(currData[i].menu_id, currData[i].parent_id, 'authority', '', currData[i].name);
            }
        }
        return d;
    }




    //自动展开
    if (document.all) {
        document.getElementById("click_me").click();
    }
    else {
        var e = document.createEvent("MouseEvents");
        e.initEvent("click", true, true);
        document.getElementById("click_me").dispatchEvent(e);
    }
})/**
 * Created by A510L on 2018/1/30.
 */
